<template>
	<f7-page>
		<f7-navbar :title="$t('settings.title')" :back-link="$t('common.back')" sliding></f7-navbar>
		<f7-list>
	  <f7-list-item link="/updatepass/" :title="$t('settings.changePassword')"><f7-icon slot="media" f7="lock"></f7-icon></f7-list-item>
	  <f7-list-item link="/geofence/" :title="$t('settings.fenceSetting.title')"><f7-icon slot="media" f7="circle"></f7-icon></f7-list-item>
		<f7-list-item link="/alarm/" :title="$t('settings.alarmSystem.title')"><f7-icon slot="media" f7="bell"></f7-icon></f7-list-item>
		<f7-list-item link="/language/" :title="$t('settings.language')" smart-select><f7-icon slot="media" f7="world"></f7-icon>
			<select name="language" v-on:change="switchLanguage($event.target.value)">
				<option value="zh_CN"  :selected="lang=='zh_CN'">中文</option>
				<option value="en"  :selected="lang=='en'">English</option>
			</select>
		</f7-list-item>
		<f7-list-item link="/switch-map/" :title="$t('settings.mapType')" :after="$store.state.map.type"><f7-icon slot="media" f7="layers"></f7-icon></f7-list-item>
		<f7-list-item link="/feedback/" :title="$t('settings.feedback.title')"><f7-icon slot="media" f7="email"></f7-icon></f7-list-item>
		<f7-list-item link="/help/" :title="$t('settings.help')"><f7-icon slot="media" f7="help"></f7-icon></f7-list-item>
		<f7-list-item link="/about/" :title="$t('settings.aboutUs')"><f7-icon slot="media" f7="flag"></f7-icon></f7-list-item>
		<f7-list-item link="#" :title="$t('settings.version')" :after="$store.state.global.version"><f7-icon slot="media" f7="info"></f7-icon></f7-list-item>
	</f7-list>

		<f7-block inner>

			<p><f7-button fill @click="exit" color="red">{{$t("settings.signOut")}}</f7-button></p>

		</f7-block>
	</f7-page>
</template>

<script>

	export default {
		data() {
				return {
					lang:localStorage.lang?localStorage.lang:'zh_CN'
				}
			},
		methods:{
				exit(){
					if(window.JPush){
						window.JPush.deleteAlias({alias:this.$store.state.user.id.toString() },
						 (result) => {
							 //window.f7.toast.create({text: '别名删除成功 ',closeTimeout: 2000,}).open();
						 }, (error) => {

						 })
					}

					 localStorage.clear();
					 this.$store.dispatch('exit');

				},
				switchLanguage(val){
					this.lang = localStorage.lang = val;
					this.$i18n.locale = val;
					this.$store.dispatch('initGlobalPropertys',[{key:'lang',value:val}])
					this.$f7.views.main.router.back();
				}
		},
	}
</script>
